package com.bawei.common.base

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import com.blankj.utilcode.util.ToastUtils
import com.gyf.immersionbar.ImmersionBar

/**
 * Author: Jason Zhang
 * Date: 2024/8/19
 * Desc: 基础Activity
 */
abstract class BaseActivity<VDB: ViewDataBinding> : AppCompatActivity(){

    lateinit var mDataBinding: VDB

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mDataBinding = DataBindingUtil.setContentView(this, getLayoutId())
        //沉浸式状态栏
        ImmersionBar.with(this).init()
        //初始化组件
        initViews()
    }

    fun showToastMsg(msg: String) {
        if (!msg.isNullOrEmpty()){
            ToastUtils.showLong(msg)
        }
    }

    abstract fun getLayoutId(): Int

    abstract fun initViews()

}